<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>

<style>
    .bg {
        background: none;
        border: none;
    }

    .uploadify-button-text {
        display: inline-flex;
    }

    .uploadify-button-text button {
        margin: -10px;
    }

    .upviewer img {
        height: 90px;
        width: 120px;
    }

    .upviewer ul {
        margin: 0px;
        padding: 0px;
    }

    .upviewer li {
        margin: 0px;
        padding: 0px;
        position: relative;
        display: inline-block;
        width: 120px;
        height: 90px;
        background-position: center;
        background-size: contain;
        background-repeat: no-repeat;
        float: left;
        margin-right: 10px;
        border: 1px #ccc solid;
        background-color: #f0f0f0;
    }

    .upviewer li a {
        display: inline-block;
        position: absolute;
        bottom: 0px;
        left: 0px;
        text-align: center;
        width: 100%;
        background-color: rgba(0, 0, 0, 0.3);
        color: red;
        cursor: pointer;
    }

    .upviewer li:hover a {
        background-color: rgba(0, 0, 0, 0.8);
    }
</style>
<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('add')}">
                <div class="form-group">
                    <label for="gift_name" class="col-sm-2 control-label">商品名称:
                        <span style="color: red;">*</span>
                    </label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="gift_name" id="gift_name" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="min_exchange" class="col-sm-2 control-label">兑换该礼品需要到达金额:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="min_exchange" id="min_exchange"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="img" class="col-sm-2 control-label">图片(290x290):
                        <span style="color: red;">*</span>
                    </label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="img">
                        <br />
                        <div name="img" class="upviewer">
                            <ul></ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script>
        $(function () {
            $("#btn").click(function () {
                var $form = $("#post_form");
                var $data = {};
                var $form_data = $form.serializeArray();
                $.each($form_data, function (k, v) {
                    $data[v['name']] = v['value'];
                })
                $.post($form.attr('action'), $data, function (obj) {
                    alert(obj.m);
                    if (obj.s) {
                        if (typeof (obj.url) != "undefined" && obj.url) {
                            location.href = obj.url;
                        }
                    }
                })
                return false;
            })
        });
    </script>